package com.ruoyi.project.system.project.service.impl;

import java.util.List;

import com.ruoyi.project.system.record.mapper.WorkRecordMapper;
import com.ruoyi.project.system.requirement.domain.Requirement;
import com.ruoyi.project.system.requirement.mapper.RequirementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.system.project.mapper.ProjectMapper;
import com.ruoyi.project.system.project.domain.Project;
import com.ruoyi.project.system.project.service.IProjectService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 项目信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2019-11-12
 */
@Service
public class ProjectServiceImpl implements IProjectService 
{
    @Autowired
    private ProjectMapper projectMapper;
    @Autowired
    private RequirementMapper requirementMapper;
    @Autowired
    private WorkRecordMapper workRecordMapper;
    /**
     * 查询项目信息
     * 
     * @param projectId 项目信息ID
     * @return 项目信息
     */
    @Override
    public Project selectProjectById(Long projectId)
    {
        return projectMapper.selectProjectById(projectId);
    }

    /**
     * 查询项目信息列表
     * 
     * @param project 项目信息
     * @return 项目信息
     */
    @Override
    public List<Project> selectProjectList(Project project)
    {
        //查询使用工作量
        List<Project> projectList = this.projectMapper.selectProjectList(project);
        if(projectList!=null&&projectList.size()>0){
            for(Project project_temp: projectList){
                String workload = this.workRecordMapper.selectWorkDayByProId(project_temp.getProjectId());
                project_temp.setWorkload(workload);
            }
        }
        return projectList;
    }

    /**
     * 新增项目信息
     * 
     * @param project 项目信息
     * @return 结果
     */
    @Override
    public int insertProject(Project project)
    {
        return projectMapper.insertProject(project);
    }

    /**
     * 修改项目信息
     * 
     * @param project 项目信息
     * @return 结果
     */
    @Override
    public int updateProject(Project project)
    {
        return projectMapper.updateProject(project);
    }

    /**
     * 删除项目信息对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteProjectByIds(String ids)
    {
        return projectMapper.deleteProjectByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除项目信息信息
     * 
     * @param projectId 项目信息ID
     * @return 结果
     */
    @Override
    public int deleteProjectById(Long projectId)
    {
        return projectMapper.deleteProjectById(projectId);
    }
}
